package src.高级;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Zuoye0428 {
    public static void main(String[] args) {
        BufferedReader a =null;
        try {
            a=new BufferedReader(new FileReader("D:\\java\\0428.txt"));
            List<String> b=new ArrayList<>();
            String c;

            while((c=a.readLine())!=null){
                b.add(c);
            }
            Scanner in=new Scanner(System.in);
            System.out.println("请输入姓名");
            String name=in.next();
            if(b.contains(name.substring(0,2))){
                System.out.println(name+"姓"+name.substring(0,2)+"，名"+name.substring(2));
            }if(b.contains(name.substring(0,1))){
                System.out.println(name+"姓"+name.substring(0,1)+"，名"+name.substring(1));
            }else{
                System.out.println(name+"的姓不存在！");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(a!=null){
                try {
                    a.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
